/*
 * (#)BaseDataProvider.java 1.0 2013-9-22 2013-9-22 GMT+08:00
 */
package com.chen.lifepic.DataProvider;

import java.util.HashMap;
import java.util.Vector;

import com.chen.lifepic.DataInfo.DataInfo;

public class BaseDataProvider {

	protected HashMap<String, DataInfo> _mediaInfosMap = null;

	protected Vector<String> _indexToKeyMap = null;

	boolean _isDataReady = false;

	public BaseDataProvider() {
		super();
	}

	public int getCount() {
		if (null == _indexToKeyMap)
			return 0;

		return _indexToKeyMap.size();
	}

	public DataInfo getItem(int index) {
		if (null == _mediaInfosMap)
			return null;

		String key = locationToKey(index);

		if (null == key)
			return null;

		return _mediaInfosMap.get(key);
	}

	public boolean ready() {
		return _isDataReady;
	}

	String locationToKey(int index) {
		if (null == _indexToKeyMap || index < 0
				|| index > _indexToKeyMap.size())
			return null;

		return _indexToKeyMap.get(index);
	}

}